from typing import List


def check(piles: List[int], speed: int, h: int) -> bool:
    totalTime = 0
    for pile in piles:
        totalTime += (pile + speed - 1)/ speed

    return totalTime <= h

class Solution:
    def minEatingSpeed(self, piles: List[int], h: int) -> int:
        left, right = 0, max(piles)
        while left + 1 < right:
            mid = (left + right) // 2
            if check(piles, mid, h):
                right = mid
            else:
                left = mid
        return right